<? include 'server_config.php'; 

if($_SESSION['user_idx'] == "k")//임시"")
{
	?>
	<script>
		location.href='login.php';
	</script>
	<?
	return;
}
?>

		
		
			<div style='height:3px;width:100%;float:left;'><span><span></div>
			<div style='height:1px;width:100%;background:#cccccc;float:left;'><span><span></div>

<?

				$sql_count ="
					SELECT COUNT(DISTINCT A.hospital_idx)
					FROM ndd_hospital_score A
					;
				";

				$result = mysql_query($sql_count,$connect);
				$row = mysql_fetch_row($result);

				$article_count = $row[0];
?>

<?

			

				$sql="
					SELECT DISTINCT A.hospital_idx
					FROM ndd_hospital_score A
					";

				$sql.="
					LIMIT ".($page)*$article_per_page.";
				";

				$result = mysql_query($sql,$connect);

				$i=0;

				while($row = mysql_fetch_row($result))
				{
					if($i==0 && $page==1)
					{
						$document_idx = $row[0];
						?>
						<script>
							
							//setTimeout('talk_display_article(<? echo $row[0];?>);',10);
							$(document).ready(function(){ hospital_display_article(<? echo $row[0];?>); });
						</script>
						<?
					}
					$i++;
					$document_hospital_idx=$row[0];
		
?>


			<div style='width:100%;float:left;cursor:pointer;' onmouseover="style.background='#F2F2F2';$('#list_arrow_<? echo $row[0];?>').show();" onmouseout="style.background='#FFFFFF';$('#list_arrow_<? echo $row[0];?>').hide();" onclick='hospital_display_article(<? echo $row[0];?>);'><!--height:99px;-->
				<div style='height:15px;width:100%;float:left;'><span>
					<!--div style='height:35px;width:35px;position:absolute;background:red;'><span></span></div-->
				</span></div>
				<div style='height:84px;width:65px;float:left;'>
					<div style='height:84px;width:14px;float:left;'></div>
					<div style='height:38px;width:38px;float:left;background:yellow;'>
					
					
						<?
							//document_hospital_idx
							$user_img = "./img/default.png";
						?>					

						<img src='<?=$user_img?>' height='38px' width='38px'>
					
					</div>
				</div>
				<div style='height:84px;width:140px;float:left;'>

				<?
					$sql2="
						SELECT * FROM ndd_hospital WHERE hospital_idx = '$document_hospital_idx' LIMIT 1
						";
					$result2 = mysql_query($sql2,$connect);
					$row2 = mysql_fetch_row($result2);

					$hospital_name = $row2[1];
					$hospital_address = $row2[2];
					$hospital_phone = $row2[4];

					$sql2="
						SELECT max(reg_timestamp), avg(q1),avg(q2),avg(q3),avg(q4),avg(q5) FROM ndd_hospital_score WHERE hospital_idx = '$document_hospital_idx'
						";
					$result2 = mysql_query($sql2,$connect);
					$row2 = mysql_fetch_row($result2);

					$hospital_update_date = substr($row2[0],0,10);
					$avg_q1 = number_format($row2[1]);
					$avg_q2 = number_format($row2[2]);
					$avg_q3 = number_format($row2[3]);


					?>
					<span id='list_id'><? echo $hospital_name; ?></span>
					<span id='list_id_detail'><br>
						<? echo $hospital_address; ?><br>
						<? echo $hospital_phone; ?><br>
					</span>
				</div>
				<div style='width:110px;float:left;padding-bottom:10px;'>
					<span id='list_article_title'>
						진료 <?=$avg_q1?><br/>
						친절 <?=$avg_q2?><br/>
						신속 <?=$avg_q3?><br/>
						<? //echo $row[7]; //등록시각?>
						<span id="date_<? echo $document_hospital_idx;?>">

						</span>
						<script>
						/*	$('#date_<? echo $document_hospital_idx;?>').text(
							
						getDateStr(<? echo substr($hospital_update_date,0,4); ?>, <? echo substr($hospital_update_date,5,2); ?>, <? echo substr($hospital_update_date,8,2); ?>, <? echo substr($hospital_update_date,11,2); ?>, <? echo substr($hospital_update_date,14,2); ?>, <? echo substr($hospital_update_date,17,2); ?>) );*/
						</script>

					<br/>
					</span>

				</div>
				<div style='height:54px;width:50px;float:left;display:none;' id='list_arrow_<? echo $row[0];?>'>
					<img src='./img/list_arrow.jpg'>
					
				</div>
	
			

			</div>
			<div style="height:1px;width:100%;background-image:url('./img/line_dot.png');float:left;"><span><span></div>
<?
				}
?>

<? //echo $article_count." ".(($page-1)*10); ?>
<?
	if ($article_count>(($page)*$article_per_page) )
	{
?> 
			<div style='height:30px;width:100%;float:left;'><span></span></div>
			<div style='float:left;height:50px;width:100%;text-align:center;'><span>
			<img id="img_show_more" src="./img/talk_view_more.png" alt="더보기" style="cursor:pointer;border:0px;" onclick="hospital_display_list('<? echo $disease_idx;?>','<? echo $page+1;?>' ); " />
			</span>
			</div>
			<div style='height:30px;width:100%;float:left;'><span></span></div>
<?
	}
	else
	{
	?>
			<div style='height:30px;width:100%;float:left;'><span></span></div>
			
			<div style='height:60px;width:100%;float:left;text-align:center;'>
			마지막 페이지 입니다.</div>
	<?
	}
	?>

<br><br>
		